def cube(num):
    num_list = []
    count = 0
    direction = 0  # 0:右；1：下；2：左；3：上
    location = [0, 0]

    for i in range(num):
        row = []
        for j in range(num):
            row.append(0)
        num_list.append(row)

    while True:
        x, y = location[0], location[1]
        try:
            if num_list[x][y] != 0:
                raise Exception
            else:
                count += 1
                num_list[x][y] = count

                if direction == 0:
                    location[1] += 1
                elif direction == 1:
                    location[0] += 1
                elif direction == 2:
                    location[1] -= 1
                elif direction == 3:
                    location[0] -= 1
        except:
            if direction == 0:
                location[1] -= 1
            elif direction == 1:
                location[0] -= 1
            elif direction == 2:
                location[1] += 1
            elif direction == 3:
                location[0] += 1
            x, y = location[0], location[1]
            count -= 1
            num_list[x][y] = 0

            direction += 1
            if direction >= 4:
                direction -= 4
        if count == num * num:
            break

    return num_list


if __name__ == "__main__":
    N = int(input(""))
    num_cube = cube(N)

    files = open("file.out", "wt")
    for i in num_cube:
        for j in i:
            files.write("%5d" % int(j))
        files.write("\n")
    files.close()

